package com.zhonghui.mes.controller;

import java.util.Date;
import java.util.List;
import java.util.UUID;
import javax.servlet.http.HttpServletResponse;

import com.zhonghui.mes.domain.vo.MesProductionSamplingVo;
import com.zhonghui.response.BaseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zhonghui.common.annotation.Log;
import com.zhonghui.common.core.controller.BaseController;
import com.zhonghui.common.enums.BusinessType;
import com.zhonghui.mes.domain.MesProductionSampling;
import com.zhonghui.mes.service.IMesProductionSamplingService;
import com.zhonghui.common.utils.poi.ExcelUtil;
import com.zhonghui.common.core.page.TableDataInfo;

/**
 * 生产采样Controller
 * 
 * @author zhonghui
 * @date 2022-05-25
 */
@RestController
@RequestMapping("/mes/sampling")
@Api(tags="制造执行MES-生产采样")
public class MesProductionSamplingController extends BaseController
{
    @Autowired
    private IMesProductionSamplingService mesProductionSamplingService;

    /**
     * 查询生产采样列表
     */
    @ApiOperation("查询生产采样列表")
    @GetMapping("/list")
    public TableDataInfo<List<MesProductionSamplingVo>> list(MesProductionSamplingVo mesProductionSamplingVo)
    {
        startPage();
        List<MesProductionSamplingVo> list = mesProductionSamplingService.selectMesProductionSamplingList(mesProductionSamplingVo);
        return getDataTable(list);
    }

    /**
     * 导出生产采样列表
     */
    @ApiOperation("导出生产采样列表")
    @Log(title = "生产采样", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MesProductionSamplingVo mesProductionSamplingVo)
    {
        List<MesProductionSamplingVo> list = mesProductionSamplingService.selectMesProductionSamplingList(mesProductionSamplingVo);
        ExcelUtil<MesProductionSamplingVo> util = new ExcelUtil<MesProductionSamplingVo>(MesProductionSamplingVo.class);
        util.exportExcel(response, list, "生产采样数据");

    }

    /**
     * 获取生产采样详细信息
     */
    @ApiOperation("获取生产采样详细信息")
    @GetMapping(value = "/{id}")
    public BaseResult<MesProductionSamplingVo> getInfo(@PathVariable("id") Long id)
    {
        return BaseResult.success(mesProductionSamplingService.selectMesProductionSamplingById(id));
    }

    /**
     * 新增生产采样
     */
    @ApiOperation("新增生产采样")
    @Log(title = "生产采样", businessType = BusinessType.INSERT)
    @PostMapping
    public BaseResult<Integer> add(@RequestBody MesProductionSampling mesProductionSampling)
    {
        return BaseResult.success(mesProductionSamplingService.insertMesProductionSampling(mesProductionSampling));
    }

    /**
     * 修改生产采样
     */
    @ApiOperation("修改生产采样")
    @Log(title = "生产采样", businessType = BusinessType.UPDATE)
    @PutMapping
    public BaseResult<Integer> edit(@RequestBody MesProductionSampling mesProductionSampling)
    {
        return BaseResult.success(mesProductionSamplingService.updateMesProductionSampling(mesProductionSampling));
    }

    /**
     * 删除生产采样
     */
    @ApiOperation("删除生产采样")
    @Log(title = "生产采样", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public BaseResult<Integer> remove(@PathVariable Long[] ids)
    {
        return BaseResult.success(mesProductionSamplingService.deleteMesProductionSamplingByIds(ids));
    }
}
